package previous.Test_0322;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 */
public class Bridge_Blue {
    //单词分析
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        String s=scan.nextLine();
        char[] c=s.toCharArray();
        Map<Character,Integer> hash=new HashMap<>();
        for (int i = 0; i < c.length; i++) {
            hash.put(c[i], hash.getOrDefault(c[i],0)+1);
        }
        int ret=0;
        char m = '0';
        for (Character x: hash.keySet()) {
            int count=hash.get(x);
            if(count>ret){
                ret=count;
                m=x;
            }
        }
        System.out.println(m);
        System.out.println(ret);
        scan.close();
    }
    //数字三角形
    public static void main3(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n=scan.nextInt();
        int[][] num=new int[n+1][n+1];
        int[][] dp=new int[n+1][n+1];
       boolean[][] vis=new boolean[n+1][n+1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                num[i][j]=scan.nextInt();
            }
        }
        //dp[i][j]:表示第i，j位置的最大路径和
        dp[0][0]=num[0][0];
        int[] dx={1,1};
        int[] dy={0,1};
        int ret=0;
        int left=0;
        int right=0;
        for (int i = 1; i < n ; i++) {
            for (int j = 0; j <= i; j++) {
                        dp[i][j]=dfs(num,dp,i,j,left,right);
                    }
                }

        for (int i = 0; i < n; i++) {
            ret=Math.max(ret,dp[n-1][i]);
        }
        System.out.println(ret);
        scan.close();
    }
    //当前行的最大值
    public static int dfs(int[][] num,int[][] dp,int i,int j,int left,int right){
        if(i==num.length) return 0;
        if(left-right<1){
            if(dp[i-1][j]+num[i+1][j]>dp[i-1][j]+num[i+1][j+1]){
                dp[i][j]=dp[i-1][j]+num[i+1][j];
                dfs(num,dp, i+1,j,left, right+1);
            }else{
                dp[i][j]=dp[i-1][j]+num[i+1][j+1];
                dfs(num,dp, i+1,j,left+1, right);
            }
        }else if(left-right>1){
            dp[i][j]+=num[i+1][j];
            dfs(num,dp, i+1,j,left, right+1);
        }else if(right-left>1){
            dp[i][j]+=num[i+1][j+1];
            dfs(num,dp, i+1,j,left+1, right);
        }
        return dp[i][j];
    }
    //寻找2020
    public static void main6(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        for (int i = 0; i < 300; i++) {

        }
        scan.close();
    }


}
